# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.BinaryAuthorization.V1.Model.PkixPublicKey do
  @moduledoc """
  A public key in the PkixPublicKey [format](https://tools.ietf.org/html/rfc5280#section-4.1.2.7). Public keys of this type are typically textually encoded using the PEM format.

  ## Attributes

  *   `keyId` (*type:* `String.t`, *default:* `nil`) - Optional. The ID of this public key. Signatures verified by Binary Authorization must include the ID of the public key that can be used to verify them. The ID must match exactly contents of the `key_id` field exactly. The ID may be explicitly provided by the caller, but it MUST be a valid RFC3986 URI. If `key_id` is left blank and this `PkixPublicKey` is not used in the context of a wrapper (see next paragraph), a default key ID will be computed based on the digest of the DER encoding of the public key. If this `PkixPublicKey` is used in the context of a wrapper that has its own notion of key ID (e.g. `AttestorPublicKey`), then this field can either match that value exactly, or be left blank, in which case it behaves exactly as though it is equal to that wrapper value.
  *   `publicKeyPem` (*type:* `String.t`, *default:* `nil`) - A PEM-encoded public key, as described in https://tools.ietf.org/html/rfc7468#section-13
  *   `signatureAlgorithm` (*type:* `String.t`, *default:* `nil`) - The signature algorithm used to verify a message against a signature using this key. These signature algorithm must match the structure and any object identifiers encoded in `public_key_pem` (i.e. this algorithm must match that of the public key).
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :keyId => String.t() | nil,
          :publicKeyPem => String.t() | nil,
          :signatureAlgorithm => String.t() | nil
        }

  field(:keyId)
  field(:publicKeyPem)
  field(:signatureAlgorithm)
end

defimpl Poison.Decoder, for: GoogleApi.BinaryAuthorization.V1.Model.PkixPublicKey do
  def decode(value, options) do
    GoogleApi.BinaryAuthorization.V1.Model.PkixPublicKey.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.BinaryAuthorization.V1.Model.PkixPublicKey do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
